//
//  YOrderMap.swift
//  EasyEverything
//
//  Created by YangZhe on 17/4/8.
//  Copyright © 2017年 kuletech. All rights reserved.
//

open class YOrderMap<T>{
    
    var yOrderMapEntities = [YOrderMapEntity<T>]()
    
    open func put(_ key:String, _ value:T){
        remove(key)
        yOrderMapEntities.append(YOrderMapEntity(key: key, value: value))
    }
    
    open func get(_ key:String) -> T?{
        for yOrderMapEntity in yOrderMapEntities{
            if yOrderMapEntity.key == key{
                return yOrderMapEntity.value
            }
        }
        return nil
    }
    
    open func remove(_ key:String){
        for (i,yOrderMapEntity) in yOrderMapEntities.enumerated(){
            if yOrderMapEntity.key == key{
                yOrderMapEntities.remove(at: i)
                break
            }
        }
    }
}

class YOrderMapEntity<T> {
    var key:String
    var value:T
    var isChecked = false
    
    init(key:String, value:T) {
        self.key = key
        self.value = value
    }
}
